package com.liuhengjia.mapper;

import com.liuhengjia.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {
    @Insert("INSERT INTO user " +
            "SET (category_name, category_alias, create_user, create_time, update_time) " +
            "VALUES (#{categoryName}, #{categoryAlias}, #{createUser}, #{createTime}, #{updateTime})")
    void insertCategory(Category category);

    @Select("SELECT id, category_name, category_alias, create_user, create_time, update_time " +
            "FROM category " +
            "WHERE create_user = #{userId}")
    List<Category> selectAll(Integer userId);

    @Select("SELECT id, category_name, category_alias, create_user, create_time, update_time " +
            "FROM category " +
            "WHERE id = #{id}")
    Category selectById(Integer id);

    @Update("UPDATE category " +
            "SET category_name = #{categoryName}, category_alias = #{categoryAlias}, update_time = #{updateTime} " +
            "WHERE id = #{id}")
    void update(Category category);

    @Delete("DELETE FROM category " +
            "WHERE id = #{id}")
    void delete(Integer id);
}
